/*
 * Copyright (c) 2023 IUV Inc. All rights reserved.
 * 项目名称：IUV TXY
 * 文件名：index.js
 * Date：23-10-11 下午5:36
 * Author：Will
 */

/*
 * 加载完后执行
 */
$(function () {
    const Base_Url = "http://127.0.0.1:8080/"; //TODO 问题四  为前端指定后台服务的API地址
    const SubmitButton = $("#submitButton");
    const mobile = $("#mobile");


    // 验证手机号
    var isPhoneNo = (phone) => {
        var pattern = /^1[34578]\d{9}$/;
        return pattern.test(phone);
    }

    
    /**
     *绑定获取事件
     **/
    SubmitButton.bind("click", () => {

        //手机号码
        let mobileNum = $.trim(mobile.val());
        //简单校验一下
        if (mobileNum.length == 0) {
            alert("请输入手机号");
        } else if (!isPhoneNo(mobileNum)) {
            alert("手机号码不正确");
        }else{
            $.get(Base_Url + "status/queryNumberStatus", {mobile: mobileNum}, (data) => {
                if(data.status == "S"){
                    var msg="手机号状态: "+data.statusInfo.status+"\n";
                    msg+="实际运营商: "+data.statusInfo.carrier+"\n";
                    alert(msg)
                }else{
                    alert(data.sysMsg)
                }
             });
        }



    });
});
